<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>百度换肤效果</title>

</head>
<style>
    * {
        padding: 0px;
        margin: 0px;
    }
    
    body {
        background-image: url(images/1.jpg);
        background-size: cover;
        /* width: 1366px; */
        /* height: 1600px;  */
        background-repeat: no-repeat;
    }
    
    .top1 {
        width: 630px;
        height: 70px;
        margin-top: 100px;
        margin-left: 365px;
        border-top: white solid 3px;
    }
    
    .top1 img {
        float: left;
        margin-left: 3px;
        width: 100px;
        /* height: 70px; */
    }
</style>

<body>
    <div class="top1">
        <img src="images/1.jpg" alt="图片">
        <img src="images/2.jpg" alt="图片">
        <img src="images/3.jpg" alt="图片">
        <img src="images/4.jpg" alt="图片">
        <img src="images/5.jpg" alt="图片">
        <img src="images/6.jpg" alt="图片">
    </div>
    <div></div>
    <div></div>
</body>
<script>
    var top1 = document.querySelectorAll('.top1 img');
    console.log(top1);
    for (var i = 0; i < top1.length; i++) {
        top1[i].onclick = function() {
            document.body.style.backgroundImage = 'url(' + this.src + ')';
            console.log('这图片路径是: ' + this.src);
        }
        top1[i].onmouseover = function() {
            this.style.cursor = 'pointer';
        }
    }
</script>

</html>